package vip.xiaonuo.biz.modular.notice.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.biz.modular.notice.entity.BizNoticeList;
import vip.xiaonuo.biz.modular.notice.param.BizNoticeGetParam;
import vip.xiaonuo.biz.modular.notice.param.BizNoticeMessageParam;
import vip.xiaonuo.biz.modular.notice.service.BizNoticeService;
import vip.xiaonuo.common.pojo.CommonResult;

import java.util.List;

/**
 * 通知类（将通知功能抽离成组件，单独调用,数据库状态复用dev_message）
 * @author xsl
 * @date 2024-07-13 10:52
 **/
@Tag(name = "通知控制器")
@RestController
@Validated
public class BizNoticeController {
    @Resource
    BizNoticeService bizNoticeService;

    /**
     * 获取通知请求的资源列表
     *
     * @author 薛守立
     * @date  2024-07-15 08:47
     */
    @Operation(summary = "获取通知请求的资源列表")
    @SaCheckPermission("/biz/notice/getList")
    @GetMapping("biz/notice/getList")
    public CommonResult<List<BizNoticeList>> getList(BizNoticeGetParam bizNoticeGetParam) {
        // 获取用户登录信息
        return CommonResult.data(bizNoticeService.getList(bizNoticeGetParam));
    }

    /**
     * 消息通知
     *
     * @author 薛守立
     * @date  2024-07-15 08:47
     */
    @Operation(summary = "消息通知")
    @SaCheckPermission("/biz/notice/sendMessage")
    @GetMapping("biz/notice/sendMessage")
    public CommonResult sendMessage(BizNoticeMessageParam bizNoticeGetParam) {
        // 获取用户登录信息
        bizNoticeService.sendMessage(bizNoticeGetParam);
        return CommonResult.ok().setMsg("消息已转至后台处理");
    }

}
